package com.koron.css2.newProjectCenter.impl;

import com.koron.css2.ServerInterface;
import com.koron.css2.newProjectCenter.bean.query.PjPubUpCostQuery;
import com.koron.css2.newProjectCenter.mapper.PjPubUpCostMapper;
import com.koron.css2.serviceManage.bean.RequestBean;
import com.koron.css2.serviceManage.bean.UserInfoBean;
import com.koron.css2.serviceManage.utils.JsonUtils;
import com.koron.util.Constant;
import org.apache.commons.lang3.StringUtils;
import org.koron.ebs.mybatis.SessionFactory;
import org.swan.bean.MessageBean;

/**
 * @Author: 苏小龙
 * @CreateTime: 2024-12-04
 * @Description: 费用项目
 * @Version: 1.0
 */
public class PjPubUpCostDelete implements ServerInterface {
    @Override
    public MessageBean<?> exec(SessionFactory factory, UserInfoBean userInfo, RequestBean req) {
        try {
            PjPubUpCostQuery query = JsonUtils.objectToPojo(req.getData(),PjPubUpCostQuery.class);
            if (StringUtils.isBlank(query.getId())){
                return MessageBean.create(Constant.MESSAGE_INT_FAIL,"ID 不能为空",null);
            }
            PjPubUpCostMapper pjPubUpInvoiceMapper= factory.getMapper(PjPubUpCostMapper.class);
            pjPubUpInvoiceMapper.deleteById(query.getId());
            return MessageBean.create(Constant.MESSAGE_INT_SUCCESS,"费用项目删除成功",null);
        } catch (Exception e) {
            logger.error("费用项目删除失败",e);
        }
        return MessageBean.create(Constant.MESSAGE_INT_FAIL,"费用项目删除失败",null);
    }
}
